//------------------------------------------------------------------------------
//SFWK Framework
//Copyright (C) 2011 SQLI

//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace SFWK.Core.DTO
{
    [DataContract] 
    public class SearchResultList<T>
    {
        #region Properties
        /// <summary>
        /// Gets the quantity of result T calculated without any paging options. 
        /// ATTENTION When paging is in use : this value is only calculated  when paging's from-value is equal to zero (for optimization reasons). Otherwize value is set to null.
        /// </summary>
        [DataMember]
        public int? NbResult;

        [DataMember]
        public List<T> Results;
        #endregion

        public SearchResultList(List<T> list, int? nbResult) : this()
        {
            this.Results.AddRange(list);
            this.NbResult = nbResult;
        }

        public SearchResultList()
        {
            this.Results = new List<T>();
            this.NbResult = null;
        }


        // - 03.09.2010 - comment unused + does not recalculate the NnResult
        //public void AddAll(SearchResultList<T> searchResultlist)
        //{
        //    foreach (T item in searchResultlist.Results)
        //    {
        //        if (!this.Results.Contains(item))
        //            this.Results.Add(item);
        //    }
        //}

        //public void AddAll(List<T> list)
        //{
        //    foreach (T item in list)
        //    {
        //        if (!this.Results.Contains(item))
        //            this.Results.Add(item);
        //    }
        //}
        //

    }
}

